package com.scuec.tourismwebsite.controller;

import com.scuec.tourismwebsite.entity.FreeformPostFavorite;
import com.scuec.tourismwebsite.entity.FreeformPostLike;
import com.scuec.tourismwebsite.service.FreeformPostFavoriteService;
import com.scuec.tourismwebsite.vo.OfficialFavorite;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("tour/v1")
public class FreeformPostFavoriteController {
    @Autowired
    private FreeformPostFavoriteService freeformPostFavoriteService;

    @GetMapping("AFavorite")
    public List<FreeformPostFavorite> selectFreeformPostFavoriteById(@RequestParam("user_id") int user_id, @RequestParam("post_id") int post_id){
        return freeformPostFavoriteService.selectFreeformPostFavoriteById(user_id,post_id);
    }

    @PostMapping("AFavorite/{user_id}/{post_id}")
    public int insertFreeformPostFavorite(@PathVariable("user_id") int user_id, @PathVariable("post_id") int post_id){
        return freeformPostFavoriteService.insertFreeformPostFavorite(user_id, post_id);
    }

    @DeleteMapping("AFavorite/{user_id}/{post_id}")
    public int deleteFreeformPostFavorite(@PathVariable("user_id") int user_id, @PathVariable("post_id") int post_id){
        return freeformPostFavoriteService.deleteFreeformPostFavorite(user_id,post_id);
    }

    @GetMapping("userOfficialFavorites")
    public List<OfficialFavorite> getUserOfficialFavorites(@RequestParam("user_id") int user_id) {
        return freeformPostFavoriteService.selectUserOfficialFavorites(user_id);
    }
}